package com.ruoyi.source.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum FlowTypeEnum {

    ALL(1, "全量"),
    CHECK(2, "撞库"),
    ;

    private Integer value;
    private String name;

    FlowTypeEnum(Integer value, String name){
        this.value = value;
        this.name = name;
    }

    public static List<Map<String, Object>> getMapList() {
        List<Map<String, Object>> listMap = new ArrayList<>();
        for (FlowTypeEnum item : values()) {
            Map<String, Object> itemMap = new HashMap<>();
            itemMap.put("name", item.getName());
            itemMap.put("value", item.getValue());
            listMap.add(itemMap);
        }
        return listMap;
    }

    public static String getNameByValue(Integer value){
        for (FlowTypeEnum typeEnum: values()){
            if (ObjectUtil.equals(value, typeEnum.getValue())){
                return typeEnum.getName();
            }
        }
        return value+"";
    }

}
